<%--
  Created by IntelliJ IDEA.
  User: tangchunyu
  Date: 2021/9/11
  Time: 15:47
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<table border="1px">

    <tr>
        <th>stuid</th>
        <th>stuName</th>
        <th>stuGender</th>
        <th>stuPhone</th>
        <th>stbornDateuid</th>
        <th>stuEmail</th>
        <th>stuAddress</th>
        <th>gradeId</th>
        <th>操作</th>
    </tr>

    <c:forEach items="${pagedata.dataList}" var="stu" varStatus="vs">
        <c:if test="${vs.index % 2==0}">
            <tr style="color:red;">
        </c:if>

        <c:if test="${vs.index % 2==1}">
            <tr style="color:blue;">
        </c:if>

        <td>${stu.stuId}</td>
        <td>${stu.stuName}</td>
        <td>${stu.stuGender}</td>
        <td>${stu.stuPhone}</td>
        <td>${stu.bornDate}</td>
        <td>${stu.stuEmail}</td>
        <td>${stu.stuAddress}</td>
        <td>${stu.gradeId}</td>
        <td>
            <a href="./studentoperater?option=updatepage&stuId=${stu.stuId}">编辑</a>
            <a href="./studentoperater?option=delete&stuId=${stu.stuId}">删除</a>
        </td>
        </tr>

    </c:forEach>

</table>

<c:if test="${pagedata.pageNum >1}">
    <a href="./studentoperater?option=querylist&pageNum=${pagedata.pageNum-1}&pageSize=${pagedata.pageSize}"> 上一页</a>
</c:if>



<%--
相当于 for(int index =1; index<=totalPage; index++){

}
--%>
<c:forEach begin="1" end="${pagedata.totoalPage}" step="1" var="index">
    <c:if test="${index != (pagedata.pageNum)}">

        <c:choose>
            <c:when test="${pagedata.pageNum<6 && index<6}">
                <a href="./studentoperater?option=querylist&pageNum=${index}&pageSize=${pagedata.pageSize}">${index}</a>
            </c:when>
            <c:when test="${pagedata.pageNum>=6 && index == pagedata.pageNum-2 }">
                <a href="./studentoperater?option=querylist&pageNum=1&pageSize=${pagedata.pageSize}">1</a>
                <a href="./studentoperater?option=querylist&pageNum=2&pageSize=${pagedata.pageSize}">2</a>
                ..
                <a href="./studentoperater?option=querylist&pageNum=${pagedata.pageNum -2}&pageSize=${pagedata.pageSize}">${pagedata.pageNum -2}</a>
                <a href="./studentoperater?option=querylist&pageNum=${pagedata.pageNum -1}&pageSize=${pagedata.pageSize}">${pagedata.pageNum -1}</a>
            </c:when>

            <c:when test="${pagedata.pageNum>=4 && index > pagedata.pageNum}">
                <c:if test="${index ==(pagedata.pageNum+1)}">
                    <a href="./studentoperater?option=querylist&pageNum=${pagedata.pageNum +1}&pageSize=${pagedata.pageSize}">${pagedata.pageNum +1}</a>

                </c:if>
                <c:if test="${index == (pagedata.pageNum+2)}">
                    <a href="./studentoperater?option=querylist&pageNum=${pagedata.pageNum +2}&pageSize=${pagedata.pageSize}">${pagedata.pageNum +2}</a>

                </c:if>
                <c:if test="${index == (pagedata.pageNum+3)}">
                    ...
                </c:if>
            </c:when>


        </c:choose>


    </c:if>

    <c:if test="${index == (pagedata.pageNum)}">
        <span style="color: red">${pagedata.pageNum}</span>
    </c:if>


</c:forEach>




<c:if test="${pagedata.pageNum < pagedata.totoalPage}">
    <a href="./studentoperater?option=querylist&pageNum=${pagedata.pageNum+1}&pageSize=${pagedata.pageSize}"> 下一页</a>
</c:if>

</body>
</html>
